<%@page import="com.hrms.pojo.Employee"%>
<%@page import="java.util.Calendar"%>
<%@page import="com.hrms.pojo.Pay"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%String basePath=request.getContextPath(); %>
<title>工资清单</title>
</head>
<body>
		<form action="<%=basePath %>/pay/payListForDate">
			<input value="年月查询" type="submit"/>
			<select name="year">
			<%	
				Calendar c=Calendar.getInstance();
				int nowYear=c.get(Calendar.YEAR);
				for(int i=nowYear;i>=1949;i--){
			%>
				<option value="<%=i%>"><%=i %></option>
			<%
				}
			%>
			</select>
			<select name="month">
			<%
				for(int i=12;i>=1;i--){
			%>
				<option value="<%=i%>"><%=i %></option>
			<%
				}
			%>
			</select>
		</form>
		<form action="<%=basePath %>/pay/payListForEm">
			<input type="submit" value="员工查询" />
			<select name="emId">
			<%
				Object obj=session.getAttribute("empAll");;
				if(obj!=null){
					List<Employee> allEmp=(List<Employee>)obj;
					for(Employee employee:allEmp){
			%>
				<option value="<%=employee.getEmId()%>"><%=employee.getEmId()+"        "+employee.getEmName() %></option>
			<%
					}
				}
			%>
			</select>
		</form>
		<div>
			<a href="<%=basePath %>/pay/payList">查询所有工资记录</a>
		</div>
		<table>
			<tr>
				<td>员工编号</td>
				<td>员工姓名</td>
				<td>当前月份</td>
				<td>基本工资</td>
				<td>加班费</td>
				<td>工龄费</td>
				<td>考勤费</td>
				<td>旷工费</td>
				<td>保险费</td>
				<td>实发工资</td>
				<td>操作</td>
			</tr>
			<%
				Object obj1=request.getAttribute("payList");
				List<Pay>payList=(List<Pay>)obj1;
				int payAgeSalary=0;
				int salary=0;
				for(Pay pay:payList){
					payAgeSalary=50*pay.getPayAge();
					salary=pay.getPayBase()+pay.getPayOvertime()+payAgeSalary+pay.getPayCheck()-pay.getPayAbsent()-pay.getPaySafety();
			%>
			<tr>
				<td><%=pay.getPayEmNumber() %></td>
				<td><%=pay.getPayEmName() %></td>
				<td><%=pay.getPayGrantTime() %></td>
				<td><%=pay.getPayBase() %></td>
				<td><%=pay.getPayOvertime() %></td>
				<td><%=payAgeSalary %></td>
				<td><%=pay.getPayCheck() %></td>
				<td><%=pay.getPayAbsent() %></td>
				<td><%=pay.getPaySafety() %></td>
				<td><%=salary %></td>
				<td><a href="<%=basePath %>/pay/<%=pay.getPayId() %>/removePayById">删除</a></td>
			</tr>
			<%
				}
			%>
		</table>
		<div id="page"></div>
		<div id="addPay">
			<a href="<%=basePath %>/pay/addPay">添加薪资</a>
		</div>
		<div id="return">
			<a href="<%=basePath%>/admin/function">返回功能页面</a>
		</div>
</body> 
</html>